<template>
  <!-- ---------------------------------------------表单 -->
  <el-form :model="ruleForm" :rules="rules" :inline="true" ref="ruleForm" label-width="90px" class="demo-ruleForm">
    <el-form-item label="业务品种" prop="serviceType">
      <el-select v-model="ruleForm.serviceType" placeholder="请选择业务品种" style="width: 170px;">
        <el-option label="融资性担保" value="1"></el-option>
        <el-option label="非融资性担保" value="2"></el-option>
        <el-option label="综合授信" value="3"></el-option>
        <el-option label="委托担保" value="4"></el-option>
        <el-option label="再担保业务" value="5"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="资料类型" prop="mateType">
      <el-select v-model="ruleForm.mateType" placeholder="请选择资料类型" style="width: 170px;">
        <el-option label="基础材料" value="1"></el-option>
        <el-option label="反担保材料" value="2"></el-option>
        <el-option label="法律文物" value="3"></el-option>
        <el-option label="保后材料" value="4"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="资料编号" prop="mateCode">
      <el-input v-model="ruleForm.mateCode" style="width: 170px;"></el-input>
    </el-form-item>
    <el-form-item label="是否公用" prop="isUse">
      <el-radio-group v-model="ruleForm.isUse">
        <el-radio label="1">是</el-radio>
        <el-radio label="0">否</el-radio>
      </el-radio-group>
    </el-form-item>
    <el-form-item label="资料名称" prop="mateName">
      <el-input v-model="ruleForm.mateName" style="width: 170px;"></el-input>
    </el-form-item>
    <el-form-item label="资料等级" prop="mateLevel">
      <el-select v-model="ruleForm.mateLevel" placeholder="请选择资料等级" style="width: 170px;">
        <el-option label="一级" value="1"></el-option>
        <el-option label="二级" value="2"></el-option>
        <el-option label="三级" value="3"></el-option>
        <el-option label="四级" value="4"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="资料类别" prop="mateCategory">
      <el-select v-model="ruleForm.mateCategory" placeholder="请选择资料类别" style="width: 170px;">
        <el-option label="企业材料" value="1"></el-option>
        <el-option label="相关报告" value="2"></el-option>
        <el-option label="个人反担保" value="3"></el-option>
        <el-option label="企业反担保" value="4"></el-option>
        <el-option label="抵质押物" value="5"></el-option>
        <el-option label="合同" value="6"></el-option>
        <el-option label="保后报告" value="7"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="银行" prop="bankName" style="display: flex;">
      <el-input type="textarea" v-model="ruleForm.bankName" style="width: 445px;"></el-input>
    </el-form-item>
    <el-form-item label="备注" prop="remarks" style="display: flex;">
      <el-input type="textarea" v-model="ruleForm.remarks" style="width: 445px;"></el-input>
    </el-form-item>
    <el-form-item style="display: block; text-align: right;">
      <el-button type="primary" @click="submitForm('ruleForm')" :loading="btnLoad">提交</el-button>
      <!-- <el-button @click="resetForm('ruleForm')">重置</el-button> -->
    </el-form-item>
  </el-form>
</template>

<script>
export default {
  data() {
    return {
      ruleForm: {
        id: "",
        bankId: "",
        bankName: "",
        isUse: "",
        mateCategory: "",
        mateCode: "",
        mateLevel: "",
        mateName: "",
        mateType: "",
        remarks: "",
        serviceType: "",
        mateRefId: ""
      },
      btnLoad: false,
      rules: {
        mateType: [
          {
            required: true,
            message: "请选择资料类型",
            trigger: "change"
          }
        ],
        mateCode: [
          {
            required: true,
            message: "请输入资料编号",
            trigger: "blur"
          }
        ],
        mateName: [
          {
            required: true,
            message: "请输入资料名称",
            trigger: "blur"
          }
        ],
        mateCategory: [
          {
            required: true,
            message: "请选择资料类别",
            trigger: "change"
          }
        ]
      }
    };
  },
  mounted() {
    // this.csh();
  },
  methods: {
    csh(row) {
      this.ruleForm.id = row.id;
      this.ruleForm.bankId = row.bankId;
      this.ruleForm.bankName = row.bankName;
      this.ruleForm.isUse = row.isUse;
      this.ruleForm.mateCategory = row.mateCategory;
      this.ruleForm.mateCode = row.mateCode;
      this.ruleForm.mateLevel = row.mateLevel;
      this.ruleForm.mateName = row.mateName;
      this.ruleForm.mateType = row.mateType;
      this.ruleForm.remarks = row.remarks;
      this.ruleForm.serviceType = row.serviceType;
      this.ruleForm.mateRefId = row.mateRefId;
    },
    submitForm(formName) {
      let that = this;
      this.$refs[formName].validate(valid => {
        if (valid) {
          // true '1', false '0'
          that.save(that.ruleForm, that.returnFlag);
        } else {
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
    save(params) {
      this.btnLoad = true;
      this.$api
        .formPost("/api/biz/baseMaterial/doModById", params)
        .then(res => {
          let flag = false;
          this.btnLoad = false;
          if (res.retHead.code === "0000000") {
            flag = true;
            this.$message({
              message: "提交成功！",
              type: "success"
            });
            this.$parent.$parent.init();
            this.$parent.$parent.dialogVisible2 = false;
          } else {
            this.$message({
              message: "提交失败！",
              type: res.retHead.message
            });
          }
        });
    }
  }
};
</script>
<style lang='scss' scoped>
</style>